package com.wens.monitor.dao;

import org.hibernate.Query;
import org.hibernate.Session;

import com.wens.monitor.model.Process;

public class ProcessDAO extends DAO {

	public static Process getProcess(String processName) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		Query q = session.createQuery("from Process p where p.name = :processName")
				.setString("processName", processName);
		Object o = q.uniqueResult();
		session.getTransaction().commit();
		if (o != null)
			return (Process)o;
		return null;
	}
	
	public static void update(Process process) {
		Session session = factory.getCurrentSession();
		session.beginTransaction();
		session.update(process);
		session.getTransaction().commit();
	}


}
